package mc0101.mccache.util;

import lombok.extern.slf4j.Slf4j;
import mc0101.mccache.entity.ComParmInf;
import mc0101.mccache.entity.SysParm;
import mc0101.mccache.factory.ComParmInfFactory;
import mc0101.mccache.holder.SysParmHolder;

@Slf4j
public class ParamProcessUtils {


	/**
	 * @Title: getComParmValueReplaceDafaultValue
	 * @Description: 根据键值对取出的通用参数是否为空对返回值进行赋值处理，若通用参数为空，则以默认值为准
	 * @param parmTyp
	 * @param parmKey
	 * @param defaultValue
	 * @return String
	 * @throws
	 */
	public static String getComParmValueReplaceDafaultValue(String parmTyp,
			String parmKey, String defaultValue) {

		ComParmInf comParmInf = ComParmInfFactory.getComParmInfByParmTypAndKey(
				parmTyp, parmKey);
		if (comParmInf == null) {
			log.warn("该parmTyp[" + parmTyp + "]，parmKey[" + parmKey
					+ "]对应的通用参数未配置或未生效");
			return defaultValue;
		} else {
			return comParmInf.getParmVal();
		}
	}

	/**
	 * @Title: getComParmValueReplaceDafaultValue
	 * @Description: 根据键值对取出的通用参数是否为空对返回值进行赋值处理，若通用参数为空，则以默认值为准
	 * @param parmTyp
	 * @param parmKey
	 * @param defaultValue
	 * @return String
	 * @throws
	 */
	public static String getSysParmValueReplaceDafaultValue(String parmTyp,
			String parmKey, String defaultValue) {

		SysParm sysParm = SysParmHolder.getSysParmByParmTypAndParmKey(parmTyp,
				parmKey);
		if (sysParm == null) {
			log.warn("该parmTyp[" + parmTyp + "]，parmKey[" + parmKey
					+ "]对应的系统参数未配置或未生效");
			return defaultValue;
		} else {
			return sysParm.getParmVal();
		}
	}

}